/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hu.arguscab.physic;

/**
 *
 * @author sharp
 */
abstract public class Vectors {

	
	static public Vector add(final Vector v1, final Vector v2) {
		Vector ret = new Vector(v1.getX() + v2.getX(), v1.getY() + v2.getY());
		return ret;
	}

	static public Vector sub(final Vector from, final Vector w) {
		Vector ret = new Vector(from.getX() - w.getX(), from.getY() - w.getY());
		return ret;
	}

	static public float dotProduct(final Vector v1, final Vector v2) {
		return (v1.getX()*v2.getX()) + (v1.getY()*v2.getY());
	}

	static public Vector crossProduct(final Vector v1, final Vector v2) {
		return null;
	}

	static public Vector multiply(final Vector v1, float s) {
		Vector ret = new Vector(v1.getX()*s, v1.getY()*s);
		return ret;
	}

	static public Vector divide(final Vector v1, float s) {
		Vector ret = new Vector(v1.getX()/s, v1.getY()/s);
		return ret;
	}

	static public Vector normalize(final Vector v) {
		float len = v.getLength();
		if ( len != 0 )
			return new Vector( v.getX()/len, v.getY()/len );
		return new Vector(0, 0);
	}

	public static Vector createRandom(int x, int y) {
		return new Vector(Math.random()*x, Math.random()*y);
	}
}
